const formData = ref({
    subject: '',
    grade: '',
    topic: '',
    questionType: '',
    difficulty: '',
    count: 5
});

const historyColumns = [
    { prop: 'id', label: 'ID', width: '80' },
    { prop: 'subject', label: '学科', width: '100' },
    { prop: 'grade', label: '年级', width: '100' },
    { prop: 'topic', label: '主题', width: '150' },
    { prop: 'questionType', label: '题型', width: '100' },
    { prop: 'content', label: '题目内容', minWidth: '200' },
    { prop: 'answer', label: '答案', minWidth: '200' },
    { prop: 'analysis', label: '解析', minWidth: '200' },
    { prop: 'difficulty', label: '难度', width: '100' },
    { prop: 'createdTime', label: '创建时间', width: '180' }
];

const generateExercises = async () => {
    try {
        loading.value = true;
        const response = await exerciseApi.generateExercises(
            formData.value.subject,
            formData.value.grade,
            formData.value.topic,
            formData.value.count
        );
        generatedExercises.value = response.data;
    } catch (error) {
        ElMessage.error('生成练习题失败：' + error.message);
    } finally {
        loading.value = false;
    }
};

async fetchHistory() {
    try {
        const response = await exerciseApi.getExerciseHistory(this.currentPage, this.pageSize)
        this.historyList = response.data
        this.total = response.total || response.data.length
    } catch (error) {
        console.error('获取历史记录失败:', error)
        ElMessage.error('获取历史记录失败')
    }
} 